import Vue from 'vue'
import Router from 'vue-router'
import routes from './routers'
import iView from 'iview'
import { setTitle } from '@/libs/util'

Vue.use(Router)
const router = new Router({
  routes,
  // base: process.env.BASE_URL,
  mode: 'history'
})

// router.beforeEach((to, from, next) => {
//   iView.LoadingBar.start()
//   // 从定义的localStorage中获取登录成功后所添加的值
//   const isLogin = localStorage.dlb?true : false;
//   if(to.path == '/login' || to.path == "/register" || to.path == '/verificationCodelogin' || to.path == "/forget" || to.path == "/forgetOne" || to.path == "/forgetTwo"){
//     next();
//   }else{
//     isLogin ? next() : next("/login")
//   }
// })

router.afterEach(to => {
  setTitle(to, router.app)
  iView.LoadingBar.finish()
  window.scrollTo(0, 0)
})

export default router
